<!DOCTYPE html>
<html class="x-admin-sm">
<head>
<meta charset="UTF-8">
<title></title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<link rel="stylesheet" href="/css/font.css">
<link rel="stylesheet" href="/css/index.css">
<script type="text/javascript" src="/lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="/js/index.js"></script>
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/layui-post.js"></script>
<style></style>
</head>
<body>
<div class="layui-fluid">
	<div class="layui-row layui-col-space15">
		<div class="layui-col-md12">
			<div class="layui-card">
				<div class="layui-card-body ">
					<form class="layui-form layui-col-space5">
						<div class="layui-inline layui-show-xs-block">
							<select id="userId" name="userId" required="" lay-verify="required" class="layui-input" lay-search>
								<option value="">请选择用户姓名</option>
							</select>
						</div>
						<div class="layui-input-inline layui-show-xs-block">
							<select id="status" name="status" required="" lay-verify="required" class="layui-input" lay-search>
								<option value="">请选择财务类型</option>
								<option value="0">支出</option>
								<option value="1">收入</option>
								<option value="2">理财</option>
							</select>
						</div>
						<div class="layui-input-inline layui-show-xs-block">
							<select id="isNoSee" name="isNoSee" required="" lay-verify="required" class="layui-input" lay-search>
								<option value="">请选择计入总账</option>
								<option value="0">不计</option>
								<option value="1">计入</option>
							</select>
						</div>
						<div class="layui-inline layui-show-xs-block">
							<input type="text" id="billRemark"  placeholder="请输入账单说明" autocomplete="off" class="layui-input">
						</div>
						<div class="layui-input-inline layui-show-xs-block">
							<select id="billMethod" name="billMethod" required="" lay-verify="required" class="layui-input" lay-search>
								<option value="">请选择支付方式</option>
							</select>
						</div>
						<div class="layui-inline layui-show-xs-block">
							<button class="layui-btn"  id="search" title="查询"><i class="layui-icon">&#xe615;</i></button>
							<a class="layui-btn layui-btn-small" style="float:right" onclick="location.reload()" title="刷新">
								<i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
						</div>
					</form>
				</div>
				<div class="layui-card-body layui-table-body layui-table-main" style="padding:0px 15px!important;">
					<table class="layui-table layui-form" id="table"></table>
				</div>
			</div>
		</div>
	</div>
</div>
</body>
<script>
layui.use(['laydate','table','form'], function(){
	let status = getQueryString("status"),billTypeId = getQueryString("billTypeId"),billMethod = getQueryString("billMethod");
	if(checkParamNotNull(status)) {
		$("#status").val(status).attr("disabled",true).removeAttr("lay-search");
		layui.form.render();
	}
	$.post(geturl()+'/enums/select?token='+sessionStorage.getItem("token"), JSON.stringify({parentEnumCode:"PAY_METHOD<->FREE_TYPE",orderByAscType:"enumCode"}), function (res) {
		for(var key in res.data.PAY_METHOD) $('#billMethod').append('<option value="'+key + '">' + res.data.PAY_METHOD[key] + '</option>');
		layui.form.render();
	}).done(function (){
		if(checkParamNotNull(billMethod)) {
			$("#billMethod").val(billMethod).attr("disabled",true).removeAttr("lay-search");
			layui.form.render();
		}
	})
	$.post(geturl()+'/billUser/select?token='+sessionStorage.getItem("token"), JSON.stringify({adminId:getQueryString("adminId"),status:0}), function (res) {
		for(var i in res.data){
			$("#userId").append('<option value="'+res.data[i].sysId+'">'+res.data[i].trueName+'</option>')
		}
		layui.form.render();
	}).done(function(){
		layui.table.render({
			elem: 'table', //指定元素
			url:geturl()+'/billDate/selectlist',
			contentType:'application/json',
			method:'post',height: $(window).height()-105, // 表格高度
			where:{"t2.adminId":getQueryString("adminId"),billDate:getQueryString("billDate"),status:status,billTypeId:billTypeId,billMethod:billMethod},
			page:true,
			totalRow: true,
			// toolbar:true,
			// defaultToolbar: ['filter', 'exports'],
			count:20,
			cellMinWidth: 80, //全局定义常规单元格的最小宽度，layui 2.2.1 新增
			cols: [[
				{title: '序号',align:"center",halign:"center",width:80,type: 'numbers', totalRowText: '合计'},
				{field:'trueName',align:"center",title:'用户姓名',width:80},
				{field:'billTime',align:"center",title: '账单时间',sort: true},
				{field:'billMoney',align:"center",sort: true,title:'账单金额',totalRow: true,
					templet:function(d){
						var color;
						if(d.status == 1) color = '#e5a201'; else if (d.status == 2) color = '#22478a';else color = '#5FB878';
						return "<div style='color:"+color+";text-align: right;'>" + parseFloat(d.billMoney).toFixed(2) + "</div>";
					}
				},
				{field:'typeName',align:"center",title:'账单类型',templet:function(d){return "<i class='layui-icon' style='font-size:12px;'>"+d.icon+"</i>&nbsp;"+d.typeName;}},
				{field:'status',align:"center",title:'财务类型',width:80,templet:function(d){ return d.status == "1"?"<span style='color:#e5a201'>收入</span>":(d.status == "2"? "<span style='color:#22478a'>理财</span>": "<span style='color:#5FB878'>支出</span>")}},
				{field:'billMethod',align:"center",title:'支付方式',templet:returnPayMethod},
				{field:'isNoSee',align:"center",title:'计入总账',templet:function(d){return "<span style='color:"+(d.isNoSee===0?"red":"")+"'>"+(d.isNoSee===0?"不计":"计入")+"</span>";}},
				{field:'billRemark',align:"center",title:'账单说明'},
			]],
		});
	})
});
$('#search').on('click', function() {
	layui.table.reload('table', {
		page: {curr: 1},
		where : {
			"t2.adminId":getQueryString("adminId"),
			status:$("#status").val(),
			"t2.sysId":$("#userId").val(),
			billRemark:$("#billRemark").val(),
			billMethod:$("#billMethod").val(),
			isNoSee:$("#isNoSee").val()
		},
	});
	return false;
});
</script>
</html>